package com.chinacache.maint.workorder.service;

import java.util.List;

import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Required;
import org.springframework.transaction.annotation.Transactional;

import com.chinacache.maint.commons.orm.hibernate.Page;
import com.chinacache.maint.commons.orm.hibernate.SimpleHibernateDao;
import com.chinacache.maint.workorder.entity.FieldClass;

@Transactional
public class FieldClassManager {
	private SimpleHibernateDao<FieldClass, Integer> fieldClassDao;

	@Required
	public void setSessionFactory(SessionFactory sessionFactory) {
		fieldClassDao = new SimpleHibernateDao<FieldClass, Integer>(sessionFactory,
				FieldClass.class);
	}

	@Transactional(readOnly = true)
	public FieldClass getFieldClass(Integer id) {
		return fieldClassDao.findById(id);
	}

	@Transactional(readOnly = true)
	public Page<FieldClass> getAllFieldClass(Page<FieldClass> page) {
		return fieldClassDao.findAll(page);
	}

	public void saveFieldClass(FieldClass fieldClass) {
		fieldClassDao.save(fieldClass);
	}

	public void deleteFieldClass(Integer id) {
		FieldClass fieldClass = fieldClassDao.findById(id);
		fieldClassDao.delete(fieldClass);
	}

	public void updateFieldClass(FieldClass fieldClass) {
		fieldClassDao.update(fieldClass);
	}

	@Transactional(readOnly = true)
	public List<FieldClass> getAllFieldClass() {
		return fieldClassDao.findAll();
	}
}
